<div id="limitBoxDiv" class="ibox no-margins no-padding no-borders">
	<div class="ibox-title p-xs ljFixBoxTitle">
		<div class="btn btn-sm btn-success" id="selectAll"><i class="fa fa-paste">全选</i></div>
		<div class="btn btn-sm btn-default" id="clearAll"><i class="fa fa-paste">清空</i></div>
		<div class="btn btn-sm btn-primary pull-right" id="btnLimitSubmit"><i class="fa fa-paste">权限设置</i></div>
	</div>
	<div style="height:40px;"></div>
	<div class="ibox-content no-margins p-xs">
		<form method="post" action="/sys/group/limit" class="pageForm required-validate" onsubmit="return validateCallback(this, pageRefresh)">
			<input type="hidden" id="gid" name="gid" th:value="${sysGroup.id}">
			<input type="hidden" id="limits" name="limits" value="">
			<input type="hidden" id="cmd5" name="cmd5" value="">
			<input type="hidden" id="uid" name="uid" value="">
			<input type="hidden" id="randomData" name="randomData" value="">
			<div class="tabs-container">
				<ul class="nav nav-tabs">
					<th:block th:each="model,vs:${sysModels}">
						<li th:if="${vs.count == 1}"
							class="active"><a data-toggle="tab" th:href="@{'#model-'+${model.id}}">[[${model.modelName}]]</a></li>
						<li th:if="${vs.count > 1}" class=""><a data-toggle="tab" th:href="@{'#model-'+${model.id}}">[[${model.modelName}]]</a></li>
					</th:block>
				</ul>
				<div class="tab-content ">
					<th:block th:each="model,vs:${sysModels}">
						<th:block th:if="${vs.count == 1}">
							<div th:id="@{'model-'+${model.id}}" class="tab-pane active" layoutH="232">
								<div class="panel-body">
									<table class="table table-striped">
										<tbody>
										<div th:if="${not #lists.isEmpty(modelResource[model.id])}"
											 th:include="sys/group/child :: groupChild"
											 th:with="index=0,level=0,treeList=${modelResource[model.id]}"></div>
										</tbody>
									</table>
								</div>
							</div>
						</th:block>
						<th:block th:if="${vs.count > 1}">
							<div th:id="@{'model-'+${model.id}}" class="tab-pane">
								<div class="panel-body">
									<table class="table table-striped">
										<tbody>
										<div th:if="${not #lists.isEmpty(modelResource[model.id])}"
											 th:include="sys/group/child :: groupChild"
											 th:with="index=0,level=0,treeList=${modelResource[model.id]}"></div>
										</tbody>
									</table>
								</div>
							</div>
						</th:block>
					</th:block>
				</div>
			</div>
		</form>
	</div>
</div>
<script>
    jQuery(function ($) {
        $("[layoutH]").layoutH();
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
        $("#selectAll").on("click", function () {
            $('input[type="checkbox"]').iCheck('check');
        });
        $("#clearAll").on("click", function () {
            $('input[type="checkbox"]').iCheck('uncheck');
        });
        $("#btnLimitSubmit").on("click", function () {
            var limits = "";
            $('input[type="checkbox"]').each(function () {
                if ($(this).is(':checked')) {
                    limits = limits + "," + $(this).val();
                }
            });
            var title = "确认提交该组权限变更么?"
            if (limits === '') {
                title = "确认清除该组权限么?";
            }
            swal({
                title: title,
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "提交",
                cancelButtonText: "取消",
                closeOnConfirm: false
            }, function () {
                $("#limits").val(limits);
                $("#limitBoxDiv form").submit();
            });
        });
    });
</script>